import { KPagingResponse, KResponse } from "./../common/response";
import { Get, Post, Provide, Put, Inject, Validate, Param } from "@midwayjs/decorator";
import BaseController from "../common/base.controller";
import UserService from "../service/user.service";

@Provide('/api/user')
export class UserController extends BaseController {
  @Inject("userService")
  private userService: UserService;
  /**
   * 获取 User 列表
   */
  @Get('s')
  async getUsers() {
    const { users, paging } = await this.userService.getUsers();
    return new KPagingResponse(users, paging);
  }


  @Get('/:uid')
  @Validate()
  async getUserInfo(@Param() uid: string) {
    const user = await this.userService.getUserById(uid);
    return new KResponse(user);
  }

  @Post('/')
  async createUser() {

  }

  @Put('/:uid')
  async updateUser() {

  }
}